﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using CommonFunction;
using System.Xml;
using System.Data;
using System.IO;

namespace Pokerist
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// 
        [STAThread]
        static void Main()
        {   
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            DeleteUrlCacheEntry("http://pokerist.com/signin/");

            //UtilityHelper helper = new UtilityHelper();
            //Pokerist_Common.NetWorkTime = helper.GetNetworkTime() ?? DateTime.MinValue;

            //string activationCode = helper.GenerateCode(helper.GetActivateString());

            //Pokerist_Common.HasLicensed = helper.checkLicense(activationCode, getActivationCode());

            //Application.Run(new PokeristMain());
            //Application.Run(new PokerPro());
            Application.Run(new DoubleClick());
            //PlayMultiplePoker multiPoker = new PlayMultiplePoker();
            //multiPoker.InitForm();

            //Application.Run(multiPoker);
        }
        
        //private static bool Expiration()
        //{
        //    return DateTime.Now.AddDays(-7).Date > expireDate;
        //}

        [DllImport("wininet.dll", SetLastError = true)]
        private static extern long DeleteUrlCacheEntry(string lpszUrlName);

        private static string getActivationCode()
        {
            try
            {
                StreamReader reader = new StreamReader(Path.Combine(Application.StartupPath, @"privsController.dll"));
                string val = reader.ReadLine();
                reader.Close();

                return getValue(val);
            }
            catch
            {
                return string.Empty;
            }
        }

        private static string getValue(string activationCode)
        {
            activationCode = activationCode.Replace("<ActivationKey>", "");
            activationCode = activationCode.Replace("</ActivationKey>", "");

            return activationCode;
        }
    }
}
